package com.hundsun.aitest.common;

import com.hundsun.aitest.model.plat.InterfaceDict;
import lombok.Data;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.stereotype.Component;

import java.util.HashMap;
import java.util.Map;

@Component
@ConfigurationProperties(prefix = "spring")
@Data
public class ApiPlatformConfig {
    private String projects;

    private Map<String, ServiceConfig> apiPlatform;

    @Data
    public static class ServiceConfig {
        private String baseUrl;
        private String email;
        private String password;
        private String serviceId;
    }

    // aml接口字典，缓存消息
    private Map<String, InterfaceDict> interfaceDictMap = new HashMap<>();

    public void addInterfaceDict(InterfaceDict interfaceDict) {
        String urlPath = interfaceDict.getUrl();
        if(!interfaceDictMap.containsKey(urlPath)) {
            interfaceDictMap.put(urlPath, interfaceDict);
        }
    }

    public InterfaceDict queryInterfaceDict(String urlPath) {
        if(interfaceDictMap.containsKey(urlPath)) {
            return interfaceDictMap.get(urlPath);
        }
        return null;
    }
}